package com.gite.nouette.admin.implementation.view;

import com.gite.nouette.admin.contract.controller.ICHandlerModule;
import com.gite.nouette.admin.contract.view.IVCommand;
import com.gite.nouette.admin.contract.view.IVHandlerModule;
import com.smartgwt.client.types.VisibilityMode;
import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.layout.SectionStack;
import com.smartgwt.client.widgets.layout.SectionStackSection;

public class VHandlerModuleImpl extends SectionStack implements IVHandlerModule {
	private ICHandlerModule c;

	public VHandlerModuleImpl() {
		setVisibilityMode(VisibilityMode.MULTIPLE);
		addSection(createMainSection());
	}

	@Override
	public String getName() {
		return getTitle();
	}

	@Override
	public void setName(String name) {
		setTitle(name);
	}

	@Override
	public ICHandlerModule getC() {
		return this.c;
	}

	@Override
	public void setC(ICHandlerModule controller) {
		this.c = controller;
	}

	@Override
	public boolean addCommand(IVCommand<?> command) {
		getMainSection().addItem((Canvas) command);
		return true;
	}

	public SectionStackSection getMainSection() {
		return getSection(0);
	}

	public SectionStackSection createMainSection() {
		SectionStackSection mainSection = new SectionStackSection(
				"Main section");
		mainSection.setExpanded(true);
		return mainSection;
	}
}
